<?php

namespace app\rest\validate;
use think\Validate;

class User extends Validate
{
    Protected $rule = [
        'name'=>['require','min'=>2,'max'=>20],
        'sex' =>['in'=>'0,1,2'],
        'age' =>['number','between'=>'1,120'],
//        'tel'=>['require','regex'=>'/^1[012]\d{9}&/']
    ];

    protected $message =[
        'name.require' =>'你是不是忘了用户名额',
        'name.min' =>'你太短了',
        'age.between' => '你是妖怪吗!'
    ];
    public function checkStatus($value)
    {
        if ($value!==1){
            return  '请选择启用用户';
        }else{
            return true;
        }
    }

}